<?php

namespace Trawind\Remotes\Repositories\Finance\Setups;

use Trawind\Basics\Enums\ServiceDomain;
use Trawind\Remotes\BaseRepository;
use Trawind\Remotes\Contracts\Repositories\Finance\Setups\CurrencyRepository;

/**
 * Class CurrencyRepositoryEloquent.
 *
 * @package namespace TrawindCloud\Repositories\Finance\Setups;
 */
class CurrencyRepositoryEloquent extends BaseRepository implements CurrencyRepository
{

    public $baseRoute='/setup/currencies';
    

    public function __construct()
    {
        $this->domain=ServiceDomain::FINANCE_DOMAIN();
    }


    public function all($columns = ['*'])
    {
        return $this->setUrl($this->baseRoute)->result();
    }


    public function find($id, $columns = ['*'])
    {
        return $this->setUrl($this->baseRoute.'/'.$id)->result();
    }


    public function create(array $attributes)
    {
        return $this->setUrl($this->baseRoute)
            ->setClientOptions(['form_params' => $attributes])
            ->result('POST');
    }



    public function update(array $attributes, $id)
    {
        return $this->setUrl($this->baseRoute.'/'.$id)
            ->setClientOptions(['form_params' => $attributes])
            ->result('PUT');
    }

    public function getCompanyCurrency(int $companyId)
    {
        return $this->setUrl('/currencies/company/'.$companyId)->result();
    }

    public function getCompanyExchangeRate(int $currencyId, int $companyId)
    {
        return $this->setUrl("/currencies/$currencyId/exchange-rate/$companyId")->result();
    }
}
